﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace IndexMarkSilverlightClient.IndexMarkServiceReference
{
    public partial class Answer
    {
        public Answer()
        {
            this.GradationsField = new ObservableCollection<Gradation>();
        }

        public int Order { get; set; }

        public String Unit { get; set; }

        /// <summary>
        /// определяет корректность ответа путем проверки корректности каждой градации и объема ответа
        /// </summary>
        public bool IsCorrect
        {
            get
            {
                //foreach (Gradation Grad in Gradations)
                //{
                //    if (!Grad.IsCorrect) return false;
                //}

                return this.Volume > 0;
            }
        }

        public override bool Equals(object obj)
        {
            return Identical(obj as Answer);
        }

        private bool Identical(Answer A)
        {
            if (A == null) return false;
            if (this.Gradations.Count != A.Gradations.Count)
            {
                return false;
            }
            else
            {
                for (int i = 0; i < this.Gradations.Count; i++)
                {
                    if (this.Gradations[i].Equals(A.Gradations[i]))
                    {
                        return false;
                    }
                }

                return true;
            }
        }

        public override int GetHashCode()
        {
            return 0;
        }

    }
}